#ifndef CU_VARIANT_H_
#define CU_VARIANT_H_

#include "Field.h"

class CuVariant
{
public:
	__device__ CuVariant();
	__device__ CuVariant(const CuVariant& other);
	__device__ ~CuVariant();

	__device__ void operator=(const CuVariant& other);

	__device__ int typeId() const;

	__device__ static CuVariant fromBoolean(const Boolean& t);
	__device__ Boolean toBoolean() const;

	__device__ static CuVariant fromInteger(const Integer& t);
	__device__ Integer toInteger() const;

	__device__ static CuVariant fromField(const Field& t);
	__device__ Field toField() const;

protected:
	__device__ void create(int type);
	__device__ void destroy();

	int m_type;
	void* m_data;
};
__device__ CuDebug operator<<(CuDebug dbg, const CuVariant& v);

__device__ int variantType(const CuVariant& v);
__device__ Mode variantMode(const CuVariant& v);

__device__ CuVariant variantFromString(Mode mode, const CuString& v);
__device__ CuString variantToString(const CuVariant& v);

__device__ Field variantToField(const CuVariant& v);
__device__ BitArray variantToBitsLe(const CuVariant& v);
__device__ CuVariant variantFromBitsLe(int type_id, const BitArray& v);

#endif // !CU_VARIANT_H_
